<template>
  <el-card shadow="hover">
    <template #header>
      <span>{{ title }}</span>
    </template>
    <vab-chart
      :init-options="initOptions"
      :option="option"
      theme="vab-echarts-theme"
    />
  </el-card>
</template>

<script>
  import VabChart from '@/extra/VabChart'
  import { getList } from '@/api/tubiao' //doDelete,

  export default {
    name: 'VabChartLine',
    components: {
      VabChart,
    },
    props: {
      title: {
        type: String,
        default: '',
      },
    },
    data() {
      return {
        initOptions: {
          renderer: 'svg',
        },
        option: {
          grid: {
            top: 20,
            right: 20,
            bottom: 40,
            left: 40,
          },
          xAxis: {
            type: 'category',
            data: ['演员总数', '领队总数', '剧组总数', '实名总数'],
          },
          yAxis: {
            type: 'value',
          },
          series: {
            data: [
              { value: 1048, name: '演员总数' },
              { value: 735, name: '演员未审核人数' },
              { value: 580, name: '演员审核人数' },
              { value: 484, name: '演员审核未通过人数' },
            ],
            type: 'line',
          },
        },
      }
    },
    created() {
      this.fetchData()
    },
    methods: {
      async fetchData() {
        this.listLoading = true
        const res = await getList()
        this.option.series.data[0].value = res.actorCount[0]
        this.option.series.data[1].value = res.leaderCount[0]
        this.option.series.data[2].value = res.crewCount[0]
        this.option.series.data[3].value = res.starUserCount[0]
        console.log(this.option.series.data)
        this.listLoading = false
      },
    },
  }
</script>
